// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import Element from 'element-ui';
import weElement from 'we-vue-element';
import 'element-ui/lib/theme-chalk/index.css';
import VueHighlightJS from 'vue-highlightjs'
import 'highlight.js/styles/mono-blue.css' // or other highlight.js
import App from './App';
import i18n from './lang' // 国际化
import router from './router';
import mockData from './mock';
import { generalFilters } from './filters';

Vue.config.productionTip = false;

// Tell Vue.js to use vue-highlightjs
Vue.use(VueHighlightJS)

Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value),
})

Vue.use(weElement, {
  WeGrid: {
    filters: { generalFilters },
    globalOptions: {
      i18n: (key, value) => i18n.t(key, value),
      autoLoading: true,
      remote: true,
      generalFilters,
      i18nPrefix: 'content',
      remoteMethod: ({ gridUrl }) => {
        if (!gridUrl) {
          return Promise.reject();
        }
        return Promise.resolve({
          data: mockData[`${ gridUrl }`],
        });
      },
    },
  },
  WeSearch: {
    globalOptions: {
      i18n: (key, value) => i18n.t(key, value),
      i18nPrefix: 'content',
      generalFilters,
      remote: true,
      // eslint-disable-next-line no-unused-vars
      remoteMethod: ({ queryParams, me, searchRole, gridUrl }) => Promise.resolve({ data: mockData[`${ gridUrl }`], queryParams, me, searchRole }),
    },
  },
  WeExport: {
    globalOptions: {
      i18n: (key, value) => i18n.t(key, value),
      i18nPrefix: 'content',
    },
  },
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  i18n,
  template: '<App/>',
});
